<%@ page contentType="text/html;charset=UTF-8" language="java" pageEncoding="UTF-8" %>
<%
    // 检查用户是否登录且是保姆角色
    Integer userId = (Integer) session.getAttribute("userId");
    Integer userRole = (Integer) session.getAttribute("userRole");
    String userName = (String) session.getAttribute("userName");

    if (userId == null) {
        response.sendRedirect("login.jsp");
        return;
    }

    if (userRole != 1) {
        response.sendRedirect("access-denied.jsp");
        return;
    }

    // 从请求属性中获取资料数据
    String nannyName = (String) request.getAttribute("nanny_name");
    String experience = (String) request.getAttribute("nanny_experience");
    String nannyType = (String) request.getAttribute("nanny_type");
    String health = (String) request.getAttribute("nanny_health");
    Float price = (Float) request.getAttribute("nanny_price");
    String description = (String) request.getAttribute("nanny_description");
    String photo = (String) request.getAttribute("nanny_photo");
%>
<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>保姆工作台</title>
    <style>
        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
            font-family: 'Microsoft YaHei', sans-serif;
        }

        body {
            background-color: #f5f7fa;
            padding: 20px;
        }

        .container {
            max-width: 1000px;
            margin: 0 auto;
            background: white;
            border-radius: 10px;
            box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
            padding: 30px;
        }

        .profile-header {
            display: flex;
            align-items: center;
            margin-bottom: 40px;
            padding-bottom: 20px;
            border-bottom: 1px solid #eee;
        }

        .profile-photo {
            width: 150px;
            height: 150px;
            border-radius: 50%;
            object-fit: cover;
            margin-right: 30px;
            border: 4px solid #3498db;
            box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
        }

        .profile-info {
            flex: 1;
        }

        .profile-info h1 {
            font-size: 28px;
            color: #2c3e50;
            margin-bottom: 10px;
        }

        .nanny-type {
            display: inline-block;
            background: #3498db;
            color: white;
            padding: 6px 15px;
            border-radius: 20px;
            font-size: 16px;
        }

        .profile-details {
            display: grid;
            grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
            gap: 25px;
            margin-bottom: 30px;
        }

        .detail-card {
            background: #f8f9fa;
            border-radius: 10px;
            padding: 25px;
            box-shadow: 0 3px 10px rgba(0, 0, 0, 0.05);
        }

        .detail-card h3 {
            color: #3498db;
            padding-bottom: 15px;
            margin-bottom: 15px;
            border-bottom: 1px solid #ddd;
            font-size: 20px;
        }

        .detail-item {
            display: flex;
            margin-bottom: 15px;
        }

        .detail-label {
            font-weight: 600;
            min-width: 120px;
            color: #555;
        }

        .detail-value {
            color: #333;
            flex: 1;
        }

        .action-buttons {
            display: flex;
            justify-content: center;
            gap: 20px;
            margin-top: 30px;
        }

        .btn {
            padding: 12px 30px;
            border-radius: 6px;
            font-size: 16px;
            font-weight: 600;
            cursor: pointer;
            transition: all 0.3s;
            text-decoration: none;
            display: inline-block;
        }

        .btn-primary {
            background: linear-gradient(90deg, #3498db, #2980b9);
            color: white;
            border: none;
        }

        .btn-primary:hover {
            background: linear-gradient(90deg, #2980b9, #2575fc);
            transform: translateY(-2px);
            box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
        }

        .btn-secondary {
            background: #ecf0f1;
            color: #2c3e50;
            border: none;
        }

        .btn-secondary:hover {
            background: #d5dbdb;
            transform: translateY(-2px);
        }

        .no-data {
            text-align: center;
            padding: 50px;
            color: #7f8c8d;
        }

        .no-data h2 {
            margin-bottom: 15px;
            font-size: 24px;
        }

        .no-data p {
            margin-bottom: 25px;
            font-size: 16px;
        }

        @media (max-width: 768px) {
            .profile-header {
                flex-direction: column;
                text-align: center;
            }

            .profile-photo {
                margin-right: 0;
                margin-bottom: 20px;
            }

            .action-buttons {
                flex-direction: column;
                gap: 10px;
            }

            .btn {
                width: 100%;
                text-align: center;
            }
        }
    </style>
</head>
<body>
    <div class="container">
        <% if (nannyName != null) { %>
            <!-- 显示资料 -->
            <div class="profile-header">
                <img src="<%= photo != null ? photo : "images/default-avatar.jpg" %>"
                     alt="保姆照片" class="profile-photo">
                <div class="profile-info">
                    <h1><%= nannyName %></h1>
                    <span class="nanny-type"><%= nannyType %></span>
                </div>
            </div>

            <div class="profile-details">
                <div class="detail-card">
                    <h3>基本信息</h3>
                    <div class="detail-item">
                        <span class="detail-label">工作经验:</span>
                        <span class="detail-value"><%= experience %></span>
                    </div>
                    <div class="detail-item">
                        <span class="detail-label">健康状态:</span>
                        <span class="detail-value"><%= health %></span>
                    </div>
                    <div class="detail-item">
                        <span class="detail-label">期望薪资:</span>
                        <span class="detail-value"><%= price %>元/月</span>
                    </div>
                </div>

                <div class="detail-card">
                    <h3>服务详情</h3>
                    <div class="detail-item">
                        <span class="detail-label">服务类型:</span>
                        <span class="detail-value"><%= nannyType %></span>
                    </div>
                    <div class="detail-item">
                        <span class="detail-label">个人简介:</span>
                        <span class="detail-value"><%= description %></span>
                    </div>
                </div>
            </div>

            <div class="action-buttons">
                <a href="nanny-profile.jsp" class="btn btn-primary">编辑资料</a>
                <a href="logout" class="btn btn-secondary">退出登录</a>
            </div>
        <% } else { %>
            <!-- 没有资料的提示 -->
            <div class="no-data">
                <h2>尚未填写资料</h2>
                <p>您还没有填写保姆资料信息，请先完善资料</p>
                <a href="nanny-profile.jsp" class="btn btn-primary">填写资料</a>
            </div>
        <% } %>
    </div>
</body>
</html>